<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>提醒功能</title>

<style>
  /* 提示框样式 */
  .reminder-popup {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: #fff;
    border: 1px solid #ccc;
    padding: 10px;
    box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.5);
  }
</style>
</head>
<body>

<!-- 选择提醒时间 -->
<input type="datetime-local" id="reminder-time">
<button id="set-reminder">设置提醒</button>
<script src="../js/jquery.js"></script>
<script>
// 定义jQuery插件
(function($) {
  $.fn.reminder = function(options) {
    // 默认参数
    var settings = $.extend({
      message: "提醒内容",
      duration: 5000, // 提示框显示时间，默认5秒
      sound: "reminder-sound.mp3" // 提示音
    }, options );

    return this.each(function() {
      var $this = $(this);
      $this.click(function() {
        
        alert(11)
        var timeString = $("#reminder-time").val();
        var time = new Date(timeString).getTime();
        var currentTime = new Date().getTime();
        if (!isNaN(time) && time > currentTime) {
          var delay = time - currentTime;
          setTimeout(function(){
            var $popup = $("<div>", {
              class: "reminder-popup",
              text: settings.message
            }).appendTo("body");

            var $closeButton = $("<button>", {
              text: "关闭"
            }).appendTo($popup);

            $popup.fadeIn();
            new Audio(settings.sound).play();
            setTimeout(function(){
              $popup.fadeOut();
            }, settings.duration);

            // 关闭提示框
            $closeButton.click(function(){
              $popup.fadeOut();
            });
          }, delay);
        }
      });
    });
  };
}(jQuery));

$(document).ready(function(){
  $("#set-reminder").reminder(); // 初始化插件
});
</script>

</body>
</html>